<?php
	$data = file_get_contents("php://input");
	$url = parse_url("http://localhost:8080/");
 
    $host = $url['host'];
    $path = $url['path'];
 
	$fp = fsockopen($host, 8080, $errno, $errstr, 30);
 
    if ($fp){
        fputs($fp, "POST $path HTTP/1.1\r\n");
        fputs($fp, "Host: $host\r\n");
        fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
        fputs($fp, "Content-length: ". strlen($data) ."\r\n");
        fputs($fp, "Connection: close\r\n\r\n");
        fputs($fp, $data);
 
        $result = ''; 
        while(!feof($fp)) {
            $result .= fgets($fp, 128);
        }
    }
    else { 
        return array(
            'status' => 'err', 
            'error' => "$errstr ($errno)"
        );
    }
	fclose($fp);
 
    $result = explode("\r\n\r\n", $result, 2);
	$content = isset($result[1]) ? $result[1] : '';
	
	echo $content;
?>